package gipfProject.games.tzaar.data;

public class TzaarData {
	public static final int
		boardCols = 9,
		boardRows = 18;
	
	private PieceData board[][];
	
	public TzaarData(){
		initializeBoard();
	}
	
	private void initializeBoard(){
		board = new PieceData[boardCols][boardRows];
		
		for (int col = 0; col < boardCols ; col++){
			for (int row = 0; row < boardRows ; row++){
				board[col][row] = new PieceData();
				if ((row + 1) % 2 == col % 2) {
					board[col][row].setToEmpty();
				}
			}
		}
		
		/*
		 * Remove all of the corner pieces that are not
		 * actually part of the board
		 */
		
		//Center location
		board[4][9].setToInvalid();
		
		//Top left
		board[3][0].setToInvalid();
		board[2][1].setToInvalid();
		board[1][2].setToInvalid();
		board[0][3].setToInvalid();
		board[0][1].setToInvalid();
		board[1][0].setToInvalid();
		
		//Top right
		board[5][0].setToInvalid();
		board[6][1].setToInvalid();
		board[7][2].setToInvalid();
		board[8][3].setToInvalid();
		board[8][1].setToInvalid();
		board[7][0].setToInvalid();
		
		//Bottom left
		board[2][17].setToInvalid();
		board[1][16].setToInvalid();
		board[0][15].setToInvalid();
		board[0][17].setToInvalid();

		//Bottom right
		board[6][17].setToInvalid();
		board[7][16].setToInvalid();
		board[8][15].setToInvalid();
		board[8][17].setToInvalid();
	}
	
	public PieceData[][] getBoard(){
		return board;
	}
	
	public PieceData getPiece(int x, int y){
		return board[x][y];
	}
}
